<?php

/*
 *简化实例化操作，使用封装函数new一个对象
 *(上线前最好是新建Help文件夹存放这些辅助函数，并配置Provider注册)
 */
function user_ins()
{
    return new App\User;
}
function question_ins()
{
    return new App\Question;
}
function answer_ins()
{
    return new App\Answer;
}
function comment_ins()
{
    return new App\Comment;
}

/* 常用入口 */
Route::get('/', function () {
    return view('welcome');
});

Route::any('api', function () {
    return ['version' => 0.1];
});

/* User-Api */
Route::any('api/user', function () {
    return user_ins()->signup();
});

Route::any('api/login', function () {
    return user_ins()->login();
});

Route::any('api/logout', function () {
    return user_ins()->logout();
});

/* Qusetion-Api */
Route::any('api/question/add', function () {
    return question_ins()->add();
});

Route::any('api/question/change', function () {
    return question_ins()->change();
});

Route::any('api/question/read', function () {
    return question_ins()->read();
});

Route::any('api/question/remove', function () {
    return question_ins()->remove();
});

/* Answer-API */
Route::any('api/answer/add', function () {
    return answer_ins()->add();
});

Route::any('api/answer/change', function () {
    return answer_ins()->change();
});

Route::any('api/answer/read', function () {
    return answer_ins()->read();
});

/* -API */
Route::any('api/comment/add', function () {
    return comment_ins()->add();
});

Route::any('api/comment/remove', function () {
    return comment_ins()->remove();
});

Route::any('api/comment/change', function () {
    return comment_ins()->change();
});

Route::any('api/comment/read', function () {
    return comment_ins()->read();
});

Route::any('api/answer/vote', function () {
    return answer_ins()->vote();
});


